<?php
namespace Modules\Activity\Http\Controllers\Admin;

use Illuminate\Http\Request;
use Illuminate\Routing\Controller;

use Illuminate\Support\Str;

use Validator;
use ThrowException;
use DB;

class ActivityController extends Controller
{

    public function statusTotal(Request $req, $type)
    {
        $rule = [
        ];
        Validator::make($req->all(), $rule)->fails() && ThrowException::BadRequest();

        $classMap = config('map.node_type');

        $type = str_replace('-', '_', $type);
        $class  = $classMap[$type];
        
        $total = [
            'on_stock' => $class::status('on_stock')->count(),
            'off_stock' => $class::status('off_stock')->count(),
            'sell_out' => $class::status('sell_out')->count(),
            // 'marked' => $class::status('marked')->count(),
        ];

        return [
            'total' => $total
        ];
    }
}
